package pikes.ecma;

import pikes.core.Printable;
import pikes.core.PrintableCharSequence;

public class Identifier extends PrintableExpression implements IPrimaryExpression {

	private Printable identifier = null;

	public Identifier(CharSequence identifier) {
		this(new PrintableCharSequence(identifier));
	}

	public Identifier(Printable identifier) {
		super();
		this.identifier = identifier;
	}

	public void visit(SyntaxTreeVisitor syntaxTreeVisitor) throws EcmaSyntaxVisitingException {
		syntaxTreeVisitor.identifier(identifier);
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Identifier) {
			Identifier thatId = (Identifier) obj;
			return identifier.equals(thatId.identifier);
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return identifier.hashCode();
	}

}
